Skip to content

Conversation

@arrayka
Copy link
Contributor

@arrayka arrayka commented Jan 23, 2026

Why

  • To avoid writes to the real filesystem in unit tests.

What

  • Removed PhysicalFS references from tests and replaced with VirtualStorageProvider::new_overlay()
  • Added vfs::PhysicalFS::new to the list of disallowed methods in clippy.toml

@arrayka arrayka requested a review from hildebrandmw January 23, 2026 08:42
@arrayka arrayka changed the title Remove PhysicalFS references from tests and replace with VirtualStorageProvider::new_overlay() Enforce no real filesystem writes during unit tests Jan 23, 2026
Copy link
Contributor

Copilot AI commented Jan 23, 2026

@arrayka I've opened a new pull request, #701, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits January 23, 2026 01:49
* Initial plan

* Address PR feedback: revert comments and refactor test helper functions

Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>

* Revert test_index_path() to return String and remove .to_string_lossy()

Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>

* Remove test_index_os_path() and use test_index_path() instead

Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>

* Revert commit 90934ad

Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>
pub fn benchmark_copy_aligned_data(c: &mut Criterion) {
let tmp_dir = TempDir::with_prefix(BENCHMARK_ID).expect("Failed to create temporary directory");
// Use physical file system rather than memory for testing the actual disk read/write
#[allow(clippy::disallowed_methods)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use

#[expect(clippy::disallowed_methods, "reason")]

to do two things:

  1. expect will complain if disallowed method is not actually used (helping with maintanence)
  2. The following reason helps document why an exception is made.

pub fn benchmark_copy_aligned_data_iai() {
let tmp_dir = TempDir::with_prefix(BENCHMARK_ID).expect("Failed to create temporary directory");
// Use physical file system rather than memory for testing the actual disk read/write
#[allow(clippy::disallowed_methods)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here with expect instead of allow.

let storage_provider = VirtualStorageProvider::new(vfs);
let pq_pivots_path: &str = "test_data/sift/siftsmall_learn_pq_pivots.bin";
let storage_provider = VirtualStorageProvider::new_overlay(workspace_root);
let pq_pivots_path: &str = "/test_data/sift/siftsmall_learn_pq_pivots.bin";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we should also do (maybe in another PR) is to replace all uses of test_data with the file system resolution in diskann-utils. I think a few fell through the cracks when test data was consolidated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. I've created an issue to track this: #704

impl VirtualStorageProvider<OverlayFS> {
/// Create a two-layer overlay filesystem with an in-memory filesystem for writes
/// on top of the physical filesystem for reads.
pub fn new_overlay<P: AsRef<std::path::Path>>(path: P) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see any value in making VirtualStorageProvider::new much harder to call to encourage use of new_overlay or new_memory? Maybe with like a new_physical and then linting that with clippy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
I've created an issue to track this: #703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants